@1787515053 在 使用小鱼的ROS2 yolov5 功能包时出现错误 中说:
运行
ros2 run yolov5_ros2 yolo_detect_2d --ros-args -p device:=cpu -p image_topic:=/image
日志
dhx@dhx:~/yolov5_ws$ ros2 run yolov5_ros2 yolo_detect_2d --ros-args -p device:=cpu -p image_topic:=/image
/opt/ros/foxy/bin/ros2:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
WARNING ⚠️ Python>=3.10 is required, but Python==3.8.10 is currently installed
[476.7030836014194, 0.0, 400.5, 0.0, 476.7030836014194, 400.5, 0.0, 0.0, 1.0] [0.0, 0.0, 0.0, 0.0, 0.0]
在另一个中断运行
ros2 run image_tools cam2image --ros-args -p width:=640 -p height:=480 -p frequency:=30.0 -p device_id:=-1正常发送
第一个终端就会报错
dhx@dhx:~/yolov5_ws$ ros2 run yolov5_ros2 yolo_detect_2d --ros-args -p device:=cpu -p image_topic:=/image
/opt/ros/foxy/bin/ros2:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
WARNING ⚠️ Python>=3.10 is required, but Python==3.8.10 is currently installed
[476.7030836014194, 0.0, 400.5, 0.0, 476.7030836014194, 400.5, 0.0, 0.0, 1.0] [0.0, 0.0, 0.0, 0.0, 0.0]
/home/dhx/.local/lib/python3.8/site-packages/yolov5/models/common.py:709: FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cuda', args...) instead.
with amp.autocast(autocast):
[INFO] [1731588917.369804689] [yolov5_ros2]: image 1/1: 480x640 1 person
Speed: 1.8ms pre-process, 50.7ms inference, 0.6ms NMS per image at shape (1, 3, 480, 640)
Traceback (most recent call last):
File "/home/dhx/yolov5_ws/install/yolov5_ros2/lib/yolov5_ros2/yolo_detect_2d", line 33, in <module>
sys.exit(load_entry_point('yolov5-ros2==0.0.0', 'console_scripts', 'yolo_detect_2d')())
File "/home/dhx/yolov5_ws/install/yolov5_ros2/lib/python3.8/site-packages/yolov5_ros2/yolo_detect_2d.py", line 163, in main
rclpy.spin(YoloV5Ros2())
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/init.py", line 191, in spin
executor.spin_once()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 719, in spin_once
raise handler.exception()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/task.py", line 239, in call
self._handler.send(None)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 429, in handler
await call_coroutine(entity, arg)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 354, in _execute_subscription
await await_or_execute(sub.callback, msg)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 118, in await_or_execute
return callback(*args)
File "/home/dhx/yolov5_ws/install/yolov5_ros2/lib/python3.8/site-packages/yolov5_ros2/yolo_detect_2d.py", line 109, in image_callback
detection2d.id = name
AttributeError: 'Detection2D' object has no attribute 'id'
dhx@dhx:~/yolov5_ws$
这个是切换galactic的分支,还是出现同样的报错